<?php
/**
* 这个是php对sql操作的类
*/
class SQLcaozuo
{


	public function lianjie(){

		require('confing.php');

		$con = new mysqli("127.0.0.1",$NAME['SQLid'],$NAME['password'],$NAME['Shujuku']);
	   if(!$con)  {  
        echo"database error";  
   		 }

   		
		return $con;

	}

	public function query($data){

		if(!$con){
			$con=$this->lianjie();
		}

   		    $con->query('set names utf8;'); 
   			//$result= array();
			$result = $con->query($data);

			 while ($tmp=mysqli_fetch_assoc($result)) {
			 	//var_dump($tmp);
        			$resulty[]=$tmp;
    		}

    
    	

		return $resulty;
		
	}

	public function query2($data){

		if(!isset($con)){
			$con=$this->lianjie();
		}

   		    $con->query('set names utf8;'); 
   			$result= array();
			$result = $con->query($data);

    
    	

		return $result;
		
	}


	public function cun($data){

		if(!$con){
			$con=$this->lianjie();
		}

   		    $con->query('set names utf8;'); 
   		
			$con->query($data);
		
	}

		
}
